package com.ruiysoft.service.order.facade;

import com.ruiysoft.entity.order.OrderDetail;
import com.ruiysoft.entity.order.OrderMain;
import com.ruiysoft.entity.order.OrderPay;
import com.ruiysoft.entity.order.OrderReceiverInfo;
import com.ruiysoft.entity.order.OrderSkuInfo;
import com.ruiysoft.entity.order.OrderSkuPic;
import com.ruiysoft.service.order.IOrderDetailService;
import com.ruiysoft.service.order.IOrderMainService;
import com.ruiysoft.service.order.IOrderOperateRecordService;
import com.ruiysoft.service.order.IOrderPayService;
import com.ruiysoft.service.order.IOrderReceiverInfoService;
import com.ruiysoft.service.order.IOrderSkuInfoService;
import com.ruiysoft.service.order.IOrderSkuPicService;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * Date : 2018/11/10
 *
 * @author WenJialu
 */
@Component
public class OrderDBHandleFacade {

	@Resource
	IOrderMainService orderMainService;
	@Resource
	IOrderPayService orderPayService;
	@Resource
	IOrderDetailService orderDetailService;
	@Resource
	IOrderSkuInfoService orderSkuInfoService;
	@Resource
	IOrderSkuPicService orderSkuPicService;
	@Resource
	IOrderReceiverInfoService orderReceiverInfoService;
	@Resource
	IOrderOperateRecordService orderOperateRecordService;

	@Transactional
	public boolean insertOrderMain(OrderMain orderMain) {
		return orderMainService.save(orderMain);
	}
	@Transactional
	public boolean insertOrderPay(OrderPay orderPay) {
		return orderPayService.save(orderPay);
	}
	@Transactional
	public boolean insertOrderDetails(List<OrderDetail> orderDetails) {
		return orderDetailService.saveBatch(orderDetails);
	}
	@Transactional
	public boolean insertOrderSkuInfos(List<OrderSkuInfo> orderSkuInfos) {
		return orderSkuInfoService.saveBatch(orderSkuInfos);
	}
	@Transactional
	public boolean insertOrderSkuPics(List<OrderSkuPic> orderSkuPics) {
		return orderSkuPicService.saveBatch(orderSkuPics);
	}
	@Transactional
	public boolean insertOrderReceiverInfo(OrderReceiverInfo orderReceiverInfo) {
		return orderReceiverInfoService.save(orderReceiverInfo);
	}

	/*public boolean insertOrderOperateRecord(Long orderId, String orderNo, OrderOperateTypeEnum typeEnum, Long operatorId){
		OrderOperateRecord record = new OrderOperateRecord();
		record.setOrderId(orderId)
				.setOrderNo(orderNo)
				.setOperateType(typeEnum.getCode())
				.setCreateTime(new Date())
				.setOperatorId(operatorId);
		return orderOperateRecordService.insert(record);
	}*/

	/*public boolean insertOrderOperateRecordBySys(String orderNo, OrderOperateTypeEnum typeEnum) {
		return insertOrderOperateRecord(null, orderNo, typeEnum, OperatorIdEnum.SYSTEM_AUTO_OPERATE.getCode());
	}*/
}
